<!DOCTYPE html>
<html lang="en">
<head>
    <script src="../js/jquery-1.8.3.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
<form id="log" class="form-horizontal" role="form">
    <div style="width: 200px;height: 100px">
    <h1>登录</h1>
    <div class="form-group">
        <label for="firstname" class="col-sm-2 control-label">账号</label>
        <div class="col-sm-10">
<input type="text" name="username" class="form-control" placeholder="请输入用户名" id="firstname">
    </div>
    </div>
    <div class="form-group">
        <label for="lastname" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-10">
<input type="password" name="password" class="form-control" placeholder="请输入密码" id="lastname">

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox"> 请记住我
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default" onclick="denglu()">登录</button>
        </div>
    </div>
    </div>
</form>
<div class="container">
    <h2>账号密码</h2>
    <p>这是公共的账号密码。</p>
    <table class="table table-striped">
        <thead>
        <tr>
            <th>账号</th>
            <th>密码</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>admin</td>
            <td>admin</td>
        </tr>
        </tbody>
    </table>
</div>

</body>
<script type="text/javascript">
    function denglu() {
        var a = $(" input[ type='text' ] ").val()
        var vts =new RegExp("admin");
        alert(a)
        if (vts.test(a)) {
            alert("管理员身份")
            tiaozhuan()
        } else {
            alert("普通用户")
            panduan()
        }
    }
    function panduan() {
            console.log("这是普通用户界面")
            $.ajax({
                url: "/login",
                data: $('#log').serialize(),
                type: "POST",
                dataType: "text",
                success: function (data) {
                    if (data === "成功") {
                        location.href = "/html/pagehelper.htm";
                    } else {
                        alert("登不进去！！！")
                    }
                }
            })
    }
    function tiaozhuan() {
        alert("跳转")
       window.open("/html/admin.htm")
    }
</script>
</html>
